﻿// 1.3.1.1.5. Subset Sums -> http://bgcoder.com/Contest/DownloadTask/9

using System;

class SubsetSums
{
    static void Main()
    {
        long s = long.Parse(Console.ReadLine());
        long n = long.Parse(Console.ReadLine());
        long[] userInput = new long[n];
        int subsetSumCounter = 0; 

        for (int i = 0; i < n; i++)
        {
            userInput[i] = long.Parse(Console.ReadLine());
        }
        int maxI = (int)Math.Pow((double)2, n) - 1;

        for (int i = 1; i <= maxI; i++)
        {
            long currentSubsetSum = 0;
            for (int j = 0; j < n; j++)
            {
                int mask = 1 << j;
                int nAndMask = i & mask;
                int bitOnJ = nAndMask >> j;
                if (bitOnJ == 1)
                {
                    currentSubsetSum += userInput[j];
                }
            }
            if (currentSubsetSum == s)
            {
                subsetSumCounter++;
            }
        }
        Console.WriteLine(subsetSumCounter);
    }
}